//
//  MCRechargePayMoneyTableViewCell.m
//  TLYL
//
//  Created by MC on 2017/6/13.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCRechargePayMoneyTableViewCell.h"

@interface MCRechargePayMoneyTableViewCell ()

//请输入充值金额
@property (nonatomic,strong) UILabel * lab_title;
//单笔充值范围为：10-50000
@property (nonatomic,strong) UILabel * lab_tip;

@end

@implementation MCRechargePayMoneyTableViewCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }    return self;

}

- (void)initView{
    
    self.backgroundColor=[UIColor  whiteColor];
    
    /*
     * 请输入充值金额
     */
    _lab_title = [[UILabel alloc]init];
    _lab_title.layer.cornerRadius=5;
    _lab_title.backgroundColor = [UIColor clearColor];
    _lab_title.layer.masksToBounds = YES;
    _lab_title.font = [UIFont systemFontOfSize:15];
    _lab_title.numberOfLines=1;
    _lab_title.textColor=[UIColor grayColor];
    _lab_title.text = @"请输入充值金额";
    _lab_title.textAlignment=NSTextAlignmentLeft;
    [self addSubview:_lab_title];

    
    /*
     * 输入框
     */
    _textField = [[UITextField alloc] init];
    _textField.layer.borderColor= [UIColor grayColor].CGColor;
    _textField.layer.borderWidth= 1.0f;
    _textField.placeholder=@"请输入充值金额";
    _textField.borderStyle = UITextBorderStyleNone;
    _textField.backgroundColor=[UIColor whiteColor];
    _textField.font = [UIFont systemFontOfSize:15];
    _textField.textColor = [UIColor blackColor];
    _textField.textAlignment = NSTextAlignmentLeft;
    _textField.returnKeyType = UIReturnKeyDone;
    _textField.keyboardType = UIKeyboardTypeDecimalPad;
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
    [self addSubview:_textField];
    
    /*
     * 单笔充值范围为：10-50000
     */
    _lab_tip = [[UILabel alloc]init];
    _lab_tip.layer.cornerRadius=5;
    _lab_tip.backgroundColor = [UIColor clearColor];
    _lab_tip.layer.masksToBounds = YES;
    _lab_tip.font = [UIFont systemFontOfSize:12];
    _lab_tip.numberOfLines=1;
    _lab_tip.textColor=[UIColor redColor];
    _lab_tip.text = @"单笔充值范围为：10-50000元";
    _lab_tip.textAlignment=NSTextAlignmentLeft;
    [self addSubview:_lab_tip];
    
    NSArray * arr_Money=@[@"100元",@"500元",@"1000元",@"10000元"];
    for (int i=0; i<4; i++) {
        UIButton * btn=[[UIButton alloc]init];
        btn.backgroundColor=[UIColor whiteColor];
        btn.layer.cornerRadius=3.0;
        btn.layer.borderColor=[UIColor grayColor].CGColor;
        [btn.layer setBorderWidth:0.5];
        btn.tag = [arr_Money[i] integerValue];
        [btn setTitle:arr_Money[i] forState:UIControlStateNormal];
        [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self addSubview:btn];
        [btn addTarget:self action:@selector(action_Btn:) forControlEvents:UIControlEventTouchUpInside];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_bottom).offset(-10);
            make.left.equalTo(self.mas_left).offset(10+i*(G_SCREENWIDTH-50)/4.0+10*i);
            make.height.mas_equalTo(30);
            make.width.mas_equalTo((G_SCREENWIDTH-50)/4.0);
        }];
    }
    [self layOutConstraints];
    
}


-(void)layOutConstraints{
    
    [_lab_title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.right.equalTo(self.mas_right).offset(-10);
        make.top.equalTo(self.mas_top).offset(10);
        make.height.mas_equalTo(20);
    }];
    
    [_textField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.right.equalTo(self.mas_right).offset(-10);
        make.top.equalTo(_lab_title.mas_bottom).offset(10);
        make.height.mas_equalTo(40);
    }];
    
    [_lab_tip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.right.equalTo(self.mas_right).offset(-10);
        make.top.equalTo(_textField.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
    }];
}

- (void)textFieldDidChange:(NSNotification *)notification
{
    
    
}

+(CGFloat)computeHeight:(id)info{
    
    return 150;
    
}

-(void)setDataSource:(id)dataSource{
    _dataSource=dataSource;
}

/*
 *  点击价格按钮
 */
-(void)action_Btn:(UIButton *)btn{
    
    _textField.text=[NSString stringWithFormat:@"%ld",(long)btn.tag];
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end



















